package model

import (
	"errors"
	"fmt"
	"server/component"
)

const (
	MsgOfflinePushedNot = 0
	MsgOfflinePushedYes = 1
)

type MsgOfflineRecord struct {
	Id          int `json:"id"`
	Msg         string
	Sender      string
	Receiver    string
	Pushed      int
	CreatedTime int `gorm:"autoCreateTime"`
	PushedTime  int `gorm:"autoCreateTime"`
}

func (MsgOfflineRecord) TableName() string {
	return "msg_offline"
}

func AddMsgOffline(data MsgOfflineRecord) error {
	result := component.Db.Create(data)
	if result.Error != nil {
		fmt.Println(result.Error)
		return errors.New("add error")
	}
	return nil
}
